package aaa;

import com.mysql.cj.jdbc.Driver;

import java.sql.*;

public class b {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
//        Class.forName("com.mysql.jdbc.Driver");
        Driver driver = new Driver();
        DriverManager.registerDriver(driver);
        String url="jdbc:mysql://localhost:3306/jdbc?useUnicode=true&characterEncoding=utf-8";
        Connection connection = DriverManager.getConnection(url, "root", "123456");
        PreparedStatement preparedStatement = connection.prepareStatement("select * from t_user");
        ResultSet resultSet = preparedStatement.executeQuery();
        while (resultSet.next()){
            System.out.println(resultSet.getString("realname"));
        }
        resultSet.close();
        preparedStatement.close();
        connection.close();

    }
}
